package com.home.java;

public class GraphicTools {

    void printRectangle() {
        for (int i = 1; i <= 5; i++) {
            for (int j = 1; j <= 5; j++) {
                System.out.print("*");
            }
            System.out.println();
        }
    }

    void printRectangle(int line, int column, String sign) {
        for (int i = 1; i <= line; i++) {
            for (int j = 1; j <= column; j++) {
                System.out.print("sign");
            }
            System.out.println();
        }
    }

    //根据底边和底边对应的高求三角形面积
    double getTriangleArea(double base, double height) {
        return base * height / 2;
    }

    //根据三角形的三条边求三角形面积，
    // 如果a,b,c不能组成三角形，打印不能组成三角形，并返回0.0
    double getTriangleArea(double a, double b, double c) {
        if (a > 0 && b > 0 && c > 0 && a + b > c && a + c > b && b + c > a) {
            double p = (a + b + c) / 2;
            return Math.sqrt(p * (p - a) * (p - b) * (p - c));
        } else {
            System.out.println(a + "," + b + "," + c + "不能构成三角形");
            return 0.0;
        }
    }
}

